package com.cf.oss.core;

/**
 * game-server-OSSConfig
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/6/5 下午 12:02
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.StringUtils;

import java.io.Serializable;

@Slf4j
@ConfigurationProperties(prefix = "zmm.oss")
public class OSSConfig implements Serializable {

    private String endpoint;
    private String accessKeyId;
    private String accessKeySecret;
    private String defaultBucketName;
    private String domain;

    public OSSConfig() {
        log.info("实例化OSSConfig");
    }

    public OSSConfig(String endpoint, String accessKeyId, String accessKeySecret) {
        Assert.hasLength(endpoint, "Parameter 'endpoint' must not be empty.");
        Assert.hasLength(endpoint, "Parameter 'accessKeyId' must not be empty.");
        Assert.hasLength(endpoint, "Parameter 'accessKeySecret' must not be empty.");
        this.endpoint = endpoint;
        this.accessKeyId = accessKeyId;
        this.accessKeySecret = accessKeySecret;
    }

    public OSSConfig setDefaultBucketName(String defaultBucketName) {
        Assert.hasLength(this.endpoint, "Parameter 'defaultBucketName' must not be empty.");
        this.defaultBucketName = defaultBucketName;
        return this;
    }

    public boolean hasDefaultBucketName() {
        return StringUtils.hasText(this.getDefaultBucketName());
    }

    public String toString() {
        return "OSSConfig(endpoint=" + this.getEndpoint() + ", accessKeyId=" + this.getAccessKeyId() + ", accessKeySecret=" + this.getAccessKeySecret() + ", defaultBucketName=" + this.getDefaultBucketName() + ")";
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public String getEndpoint() {
        return endpoint;
    }

    public void setEndpoint(String endpoint) {
        this.endpoint = endpoint;
    }

    public String getAccessKeyId() {
        return accessKeyId;
    }

    public void setAccessKeyId(String accessKeyId) {
        this.accessKeyId = accessKeyId;
    }

    public String getAccessKeySecret() {
        return accessKeySecret;
    }

    public void setAccessKeySecret(String accessKeySecret) {
        this.accessKeySecret = accessKeySecret;
    }

    public String getDefaultBucketName() {
        return defaultBucketName;
    }
}
